package jaxb.cow;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

public class JaxbUtilsTest
{
    
    @Test
    public final void testObj2xml()
    {
        ExcelMappingSheet sheet= new ExcelMappingSheet();
        sheet.setClassName("com.kedacom.sales.contract.vo.ContractDeliveryNoteVO");
        sheet.setSheetNo(1);
        
        List<ExcelMappingUnit> units = new ArrayList<ExcelMappingUnit>();
        sheet.setUnits(units);
        
        ExcelMappingUnit unit1 = new ExcelMappingUnit();
        unit1.setCellXY("A2");
        unit1.setField("contract.baseInfoVO.areaSheng");
        units.add(unit1);
        
        ExcelMappingUnit unit2 = new ExcelMappingUnit();
        unit2.setCellXY("C2");
        unit2.setField("masterAgency");
        units.add(unit2);
        
        List<ExcelMappingZone> zones = new ArrayList<ExcelMappingZone>();
        sheet.setZones(zones);
        
        ExcelMappingZone zone = new ExcelMappingZone();
        zone.setStartXY("");
        zone.setField("nodes");
        zone.setUnits(units);
        zones.add(zone);
        
        JaxbUtils.obj2xml(sheet, "D:/jaxb-sheet.xml");
    }
    
    public final void testXml2Obj()
    {
        File file = new File("D:/发货通知单_mapping.xml");
        JaxbUtils.xml2Obj(file, ExcelMappingSheet.class);
    }
    
}
